package com.by.dao;

import com.by.entity.Tb;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component("tbDaoNamed")
public class TbDaoNamedImpl implements TbDao{
    @Autowired
    private NamedParameterJdbcTemplate namedTemplate;
    @Override
    public List<Tb> getAllTbs() {
        return null;
    }

    @Override
    public List<Tb> getTbsByCond(Tb tb) {
        return null;
    }

    @Override
    public int savaTb(Tb tb) {
        String sql = "insert into tb(user_name,course,score,deptid) values(:user_name,:course,:score,:deptid)";
        Map map = new HashMap();
        map.put("user_name",tb.getUser_name());
        map.put("course",tb.getCourse());
        map.put("score",tb.getScore());
        map.put("deptid",tb.getDeptid());
        return namedTemplate.update(sql,map);
    }

    @Override
    public Tb getTbById(int id) {
        return null;
    }

    @Override
    public int updateTb(Tb tb) {
        return 0;
    }

    @Override
    public int dalTb(Tb tb) {
        return 0;
    }
}
